#include "widget.h"
#include "ui_widget.h"
#include <QLabel>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QLabel* label1 = new QLabel(ui->tab1);
    label1->setText("标签页1");

    QLabel* label2 = new QLabel(ui->tab2);
    label2->setText("标签页2");
}

Widget::~Widget()
{
    delete ui;
}




void Widget::on_pushButton_insert_clicked()
{
    int count = ui->tabWidget->count();
    QWidget* w= new QWidget(ui->tabWidget);
    ui->tabWidget->addTab(w, QString("Tab ") + QString::number(count + 1));

    QLabel* labe1 = new QLabel(w);
    labe1->setText(QString("标签页") + QString::number(count + 1));

    ui->tabWidget->setCurrentIndex(count);
}

void Widget::on_pushButton_remove_clicked()
{
    int index = ui->tabWidget->currentIndex();
    ui->tabWidget->removeTab(index);
}
